package org.opensuse.bs.ui.model;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.ISharedImages;
import org.opensuse.bs.ui.BSUIPlugin;
import org.opensuse.bs.ui.IBSUIConstants;

public class RemoteFile extends BSModelElement {
	public RemoteFile(String name, Object parent) {
		super(name, parent);
	}

	public Object[]  fetchChildren(Object object, IProgressMonitor monitor) {
		return new Object[0];
	}
	
	public ImageDescriptor getImageDescriptor(Object object) {
		BSUIPlugin plugin = BSUIPlugin.getDefault();
			if(name.endsWith(".spec")) {
				return plugin.getImageDescriptor(IBSUIConstants.IMG_SPEC_FILE);
			}
			else if(name.endsWith(".tar.gz") || name.endsWith(".tar.bz2") 
					|| name.endsWith(".tar") || name.endsWith(".zip")
					||name.endsWith(".gz") || name.endsWith(".bz2")) {
				return plugin.getImageDescriptor(IBSUIConstants.IMG_PACKAGE_FILE);
			}
			else if(name.endsWith(".jar")) {
				return plugin.getImageDescriptor(IBSUIConstants.IMG_JAR_FILE);
			}
			else {
				return plugin.getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
			}
	}
	
	public Object getParent(Object o) {
		if(o instanceof RemoteFile)
			return (RemotePackage)parent;
		return null;
	}
}
